package com.communal.model.cr;

import java.io.Serializable;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.communal.model.tarif.TarifRent;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
@Entity
@Table(name = "rent")
@AttributeOverrides({
	@AttributeOverride(name="id", column=@Column(name="id")),
	@AttributeOverride(name="enabled", column=@Column(name="enabled")),
	@AttributeOverride(name="month", column=@Column(name="month")),
	@AttributeOverride(name="year", column=@Column(name="year")),
	@AttributeOverride(name="date", column=@Column(name="date")),
	@AttributeOverride(name="summa", column=@Column(name="summa"))
})
@AssociationOverrides({
	@AssociationOverride( name="model", joinColumns = @JoinColumn(name="model_id"))
})
public class CRRent extends CommunalRecord implements Serializable{

	private static final long serialVersionUID = -1926654972484510946L;
	
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "tarif_id")
	private TarifRent tarif;
	
	/**
	 * Returns rent tarif <br>
	 * @return {@link TarifRent};
	 */
	public TarifRent getTarif() {
		return tarif;
	}

	/**
	 * Sets rent tarif <br>
	 * @param p_tarif - {@link TarifRent};
	 */
	public void setTarif(TarifRent p_tarif) {
		tarif = p_tarif;
	}
}
